package com.supervision.manage.controller

import com.fly.base.annotation.AuthPermission
import com.fly.base.common.DataResponse
import com.fly.base.redis.RedisService
import com.fly.base.util.DateFormatUtil
import com.fly.base.util.Util
import com.supervision.manage.common.DXKey
import com.supervision.manage.bean.dto.ExcelDemoDTO
import com.xuxueli.poi.excel.ExcelImportUtil
import org.apache.commons.text.StringSubstitutor
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile


/**
 * Created by whis on 2019-06-16
 * @author whis
 */
@RestController
class TestController {

    @Autowired
    lateinit var redisService: RedisService

    @RequestMapping("test")
    @AuthPermission(needToken = false)
    fun test(): DataResponse {
//        val list: List<ExcelDemoDTO> = ExcelImportUtil.importExcel(file.inputStream, ExcelDemoDTO::class.java) as List<ExcelDemoDTO>

        val param = hashMapOf<String, String>()
        param["name"] = "whis"
        param["age"] = "19"
        val template = "\${name} is at the age o f \${age}"

        val stringSubstitutor = StringSubstitutor(param)
        stringSubstitutor.replace(template)

        return DataResponse.create()
    }

    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            val param = hashMapOf<String, String>()
            param["name"] = "whis"
            param["age"] = "19"
            val template = "\${name} is at the age o f \${age}"

            val stringSubstitutor = StringSubstitutor(param)
            val rst = stringSubstitutor.replace(template)
            println(rst)
        }
    }


}
